package edu.sysu.cshare.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;

import edu.sysu.cshare.model.Message;
import edu.sysu.cshare.model.User;
import edu.sysu.cshare.service.MessageService;
import edu.sysu.cshare.service.UserService;

@Controller
@Scope("prototype")
public class MessageAction extends ActionSupport {

	private UserService userService;
	private MessageService messageService;
	private String userId;
	private User user;
	private boolean showClassMsg;
	private boolean showCourseMsg;
	private boolean showOtherMsg;
	private List<Message> messages;

	@Resource
	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	@Resource
	public void setMessageService(MessageService messageService) {
		this.messageService = messageService;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public User getUser() {
		return user;
	}

	public boolean getShowClassMsg() {
		return showClassMsg;
	}

	public void setShowClassMsg(boolean showClassMsg) {
		this.showClassMsg = showClassMsg;
	}

	public boolean getShowCourseMsg() {
		return showCourseMsg;
	}

	public void setShowCourseMsg(boolean showCourseMsg) {
		this.showCourseMsg = showCourseMsg;
	}

	public boolean getShowOtherMsg() {
		return showOtherMsg;
	}

	public void setShowOtherMsg(boolean showOtherMsg) {
		this.showOtherMsg = showOtherMsg;
	}

	public List<Message> getMessages() {
		return messages;
	}

	public String viewMessage() {
		user = userService.get(userId);
		messages = messageService.loadAll();
		return SUCCESS;
	}
	
}
